﻿<link href="@Url.Content("~/content/activitie_list.css")" rel="stylesheet" type="text/css"/>


@model IEnumerable<PessModel.Activity>

@{
    ViewBag.Title = "活动";
}
<div id="m-title">
    <h2>活动</h2>
    @if(Roles.IsUserInRole(Membership.GetUser().UserName,"Admin"))
    {
        <div id="m-op">
        @using (Html.BeginForm("Index", "Activity", FormMethod.Get))
{
    <div>
        @Html.DropDownList("PessTypeID", (string)ViewBag.pessType) <input type="submit" value="搜索" class="u-btn">
        &#8195;@Html.ActionLink("新建", "Create", null, null, new { @class = "u-btn-a " })
    </div> }
        </div>
    }
</div>

<div id="m-hd-list">
        @foreach (var item in Model)
{
    <dl onclick="window.location.href='@Url.Content("~/Activity/Details/")'+this.id;" class="bs-callout bs-callout-noleft" id=@item.ID>
        <dt>
            @if (Roles.IsUserInRole(Membership.GetUser().UserName, "ExpertJudge"))
            {
                @Html.ActionLink(item.Name, "Index", "Archive", new { activityID = item.ID }, null)
            }
            else
            {
                @Html.ActionLink(item.Name, "Details", new { id = item.ID })
            }
        </dt>
        <dd class="desc">
            @{
            string description = item.Description;
            description = description.StripHtmlTags();
            description = description.Truncate(150);
            }
            @Html.DisplayFor(modelItem => description)
        </dd>
        <dd class="startTime">
            开始时间：@Html.DisplayFor(modelItem => item.StartDate)
        </dd>
        <dd class="dueTime">
            截止时间：@Html.DisplayFor(modelItem => item.DueDate)
        </dd>
        @*<dd class="pic">
    @Html.PhotoImage(string.Format("~/images/") + item.Status + ".png")
    @Html.DisplayFor(modelItem=>item.Status)
        </dd>*@
        <dd class="link">
            @if (!Roles.IsUserInRole(Membership.GetUser().UserName, "ExpertJudge"))
            {
                @Html.ActionLink("详细", "Details", new { id = item.ID })
            }
            else
            {
                @Html.ActionLink("评分", "Index", "Archive", new { activityID = item.ID }, null)
            }
            @if (Roles.IsUserInRole(Membership.GetUser().UserName, "Admin"))
            {
                <span> | </span>@Html.ActionLink("删除", "Delete", new { id = item.ID })
            }
        </dd>
    </dl>
    <script language="javascript">
        document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.borderLeftStyle="solid";
        document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.borderLeftWidth="5px";
        switch (@item.Status) {
            case 0:
                    //document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.backgroundImage = url('<%=this.ResolveUrl("~/images/0.png") %>');
                    document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.borderLeftColor="#7db500";
                break;
            case 1:
                    //document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.backgroundImage = url('<%=this.ResolveUrl("~/images/1.png") %>');
                    document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.borderLeftColor="#e9e9e9";
                break;
            case 2:
                    //document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.backgroundImage = url('<%=this.ResolveUrl("~/images/2.png") %>');
                    document.getElementsByTagName("dl")[document.getElementsByTagName("dl").length - 1].style.borderLeftColor="#e54028";
                break;
        }
    </script>

}
</div>



<table style="display:none">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Description)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StartDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.DueDate)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AdminYear)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Status)
        </th>
@*        <th>
            @Html.DisplayNameFor(model => model.ProposalActivity.Name)
        </th>*@
        <th>
            @Html.DisplayNameFor(model => model.PessType.Name)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Description)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.StartDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DueDate)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.AdminYear)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Status)
        </td>
@*        <td>
            @Html.DisplayFor(modelItem => item.ProposalActivity.Name)
        </td>*@
        <td>
            @Html.DisplayFor(modelItem => item.PessType.Name)
        </td>
        <td>
            @Html.ActionLink("编辑", "Edit", new { id=item.ID }) |
            @*@Html.ActionLink("详细", "Details", new { id=item.ID }) |*@
            @Html.ActionLink("删除", "Delete", new { id=item.ID })
        </td>
    </tr>
}
</table>

